from flask import Blueprint, jsonify
from controllers.file_controller import get_detection_files_list, get_detection_file_content, get_rootheal_files_list, get_rootheal_file_content

files_bp = Blueprint('files', __name__)

# 获取detection_data目录下的文件列表，即前端的 api/files
@files_bp.route('/', methods=['GET'])
def list_files():
    return jsonify(get_detection_files_list())

# 获取detection_data目录下的特定文件内容
@files_bp.route('/<filename>', methods=['GET'])
def get_file(filename):
    return jsonify(get_detection_file_content(filename))



# 创建新的蓝图用于rootheal_data目录
rootheal_files_bp = Blueprint('rootheal_files', __name__)

# 获取rootheal_data目录下的文件列表
@rootheal_files_bp.route('/', methods=['GET'])
def list_rootheal_files():
    return jsonify(get_rootheal_files_list())

# 获取rootheal_data目录下的特定文件内容
@rootheal_files_bp.route('/<filename>', methods=['GET'])
def get_rootheal_file(filename):
    return jsonify(get_rootheal_file_content(filename))